package com.chance.cc.crawler.development.command.trigger.domain.xhs.monitor;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.development.command.job.domain.xhs.monitor.XHSNodeMonitorScheduleJob;
import com.chance.cc.crawler.development.command.job.domain.xhs.monitor.XHSSchedulerMonitorScheduleJob;
import com.chance.cc.crawler.development.command.trigger.CrawlerJobTriggerCommand;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;

import static com.chance.cc.crawler.development.command.publish.douyin.DYPublishCrawlerJob.metaServerIP;
import static com.chance.cc.crawler.development.command.publish.douyin.DYPublishCrawlerJob.metaServerPort;

/**
 * @author bx
 * @date 2020/12/7 0007 11:15
 */
public class XHSMonitorScheduleTrigger {


    private static CrawlerJobTriggerCommand crawlerJobTriggerCommand =
            new CrawlerJobTriggerCommand(metaServerIP,metaServerPort);

    public static void main(String[] args) {
        publishNodeSearchScheduleTriggerInfo();
        publishSchedulerSearchScheduleTriggerInfo();
    }

    public static void publishNodeSearchScheduleTriggerInfo(){
        CrawlerJob crawlerJob = XHSNodeMonitorScheduleJob.crawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                XHSNodeMonitorScheduleJob.domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0/1 * * * ?",
                "小红书采集节点监控调度");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishSchedulerSearchScheduleTriggerInfo(){
        CrawlerJob crawlerJob = XHSSchedulerMonitorScheduleJob.crawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                XHSSchedulerMonitorScheduleJob.domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0/1 * * * ?",
                "小红书调度节点监控调度");
        System.out.println("添加采集调度： "+page.getRawText());
    }
}
